<?php
use Classes\autoload\SplClassLoader;
use Classes\db\DBConnection;
use Classes\Login;
use Classes\UserPrincipal;
use html\RenderHTML;

require 'Classes/autoload/SplClassLoader.php';
$loader = new SplClassLoader ();
$loader->register ();

session_start ();

if (isset ( $_SESSION ['userPrincipal'] )) {
	header ( "Location: home.php" );
	exit ();
}

html\RenderHTML::renderHeader ( 'Веселите футболисти' );
html\RenderHTML::addStyle ( 'styles/global.css' );
html\RenderHTML::addStyle ( 'styles/index.css' );
html\RenderHTML::renderBody ();

echo '<header id="main-header">
		<div id="logo">
			<img src="images/logo1.1.jpg" alt="logo"/>
		</div>
		<input type="text" id="input-search" placeholder="Search" />
	</header>
	<hr style="border-color: threedlightshadow; margin-top: -1px">
	<h1 id="welcome">Българска футболна социална мрежа</h1>
	<div id="content">
		<form action="index.php" method="post" id="login">
			<fieldset>
				<legend>Влез</legend>
				<div id="username-div">
					<label for="username">Потребителско име:</label> <input
						type="text" name="username" id="username"/>
				</div>
				<div id="password-div">
					<label for="password">Парола:</label> <input type="password"
						name="password" id="password"/>
				</div>
				<input type="submit" value="Вход" id="submit" name="submit"/>
			</fieldset>
		</form>
		<p id="loginMsg">
			Не си регистриран? Регистрирай се <a href="register.php">Тук</a>
		</p>
';
html\RenderHTML::renderFooter ();

if (isset ( $_POST ['submit'] )) {
	Classes\Login::loginUser ( $_POST ['username'], $_POST ['password'] );
}

